<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/28 0028
 * Time: 9:49
 */

namespace app\admin\controller;


use think\Cache;
use think\Db;

class Wap extends Middle
{

    //todo 首页的实时数据的币种
    public function WapSixData(){
        $list = Cache::get('wapsixdata');
        if(!$list)return $this->returnError($this->NoData);
        foreach ($list as $k=>$v){
            $array[$k]['name'] = strtoupper($v['name']);
        }
        return $this->returnSuccess($list);
    }

    public function Count(){
        $key = 'AdminCount';
        $list = unserialize($this->redis->get($key));
        if(!$list){
            $user = Db::name('user')->count();
            $vip  = Db::name('user_service')->where(['vip'=>['>',0]])->count();
            $zn   = Db::name('user_service')->where(['zn'=>['>',0]])->count();
            $nx   = Db::name('user_service')->where(['nx'=>['>',0]])->count();
            $cl   = Db::name('user_service')->where(['cl'=>['>',0]])->count();
            $list = [
                'user'  =>$user,
                'vip'   =>$vip,
                'zn'    =>$zn,
                'cl'    =>$cl,
                'nx'    =>$nx,
            ];
            $this->redis->set($key,serialize($list),3600);
        }
        return $this->returnSuccess($list);


    }
}